package com.solver.mapper;

import com.github.pagehelper.Page;
import com.solver.annotation.AutoFill;
import com.solver.dto.TeacherPageQueryDTO;
import com.solver.entity.Teacher;
import com.solver.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TeacherMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from teacher where username = #{username}")
    Teacher getByUsername(String username);

    @Insert("insert into teacher (name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user) " +
            "values " +
            "(#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    @AutoFill(value = OperationType.INSERT)
    void insert(Teacher teacher);

    /**
     * 分页查询
     * @param teacherPageQueryDTO
     * @return
     */
    Page<Teacher> pageQuery(TeacherPageQueryDTO teacherPageQueryDTO);

    @AutoFill(value = OperationType.UPDATE)
    void update(Teacher teacher);

    @Select("select * from `tiger-solver`.teacher where id = #{id}")
    Teacher getById(Long id);
}
